package sr.myserver.controller;

import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sr.myserver.entity.SysButtons;
import sr.myserver.service.SysButtonsService;
import sr.myserver.vo.SelectData;
import sr.myserver.vo.common.Basic;
import sr.myserver.vo.common.PageRequest;
import sr.myserver.vo.common.PageResponse;

/**
 * 按钮管理
 */
@Slf4j
@RestController
@RequestMapping("/sysbuttons")
@Api(tags = "按钮管理")
public class SysButtonsController {

    @Autowired
    SysButtonsService sysButtonsService;

    /**
     * 指定ID获取数据
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @Operation(summary = "指定ID获取数据")
    public SysButtons get(@PathVariable("id") String id) {
        return sysButtonsService.get(id);
    }

    /**
     * 添加数据
     *
     * @param entity
     * @return
     */
    @PostMapping
    @Operation(summary = "添加数据")
    public Basic.Response post(@RequestBody SysButtons entity) {
        return sysButtonsService.add(entity);
    }

    /**
     * 指定ID修改数据
     *
     * @param entity
     * @return
     */
    @PutMapping("/edit")
    @Operation(summary = "指定ID修改数据")
    public Basic.Response put(@RequestBody SysButtons entity) {
        return sysButtonsService.update(entity);
    }

    /**
     * 指定ID删除数据
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    @Operation(summary = "指定ID删除数据")
    public Basic.Response delete(@PathVariable("id") String id) {
        return sysButtonsService.deleteById(id);
    }

    /**
     * 分页列表数据
     *
     * @param request
     * @return
     */
    @PutMapping
    @Operation(summary = "分页列表数据")
    public PageResponse<SysButtons> queryTables(@RequestBody PageRequest request) {
        return sysButtonsService.queryTables(request);
    }

    /**
     * 分页下拉数据
     *
     * @param request
     * @return
     */
    @PostMapping("/select")
    @Operation(summary = "分页下拉数据")
    public PageResponse<SelectData> querySelect(@RequestBody PageRequest request) {
        return sysButtonsService.querySelect(request);
    }

}

